#include<stdio.h>
#include<stdlib.h>
#define MAX_NUM 100
#define MAX_LEN 20
int main(){
	char str[] = "  This  is  a  demo";
	char sub_str[MAX_NUM][MAX_LEN];
	int i=0,j=0,k=0,len;
	len = strlen(str);
	while(i<len){
		while(i<len && str[i] == 32)
		    i++;
		j = i;
		while(i<len && str[i] != 32)
		    i++;
		strncpy(sub_str[k],str+j,i-j);
		sub_str[k][i-j] = ',';
		sub_str[k][i-j+1] = 0;
		k++;
	}
	for(k=0;k<MAX_NUM;k++){
		len =strlen(sub_str[k]);
		if(!len)
		    break;
		printf("%s",sub_str[k]);
	}
	return 0;
}